//
//  HNShoppingViewController.m
//  baidaifu
//
//  Created by 朱传正 on 2017/1/18.
//  Copyright © 2017年 haoniu. All rights reserved.
//

#import "HNShoppingViewController.h"
#import "HNPharmacyViewController.h"

@interface HNShoppingViewController ()<UIWebViewDelegate>

@end

@implementation HNShoppingViewController

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = NO;
    }
    
}

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    //在其他离开改页面的方法同样加上下面代码
    if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    }
}

-(void)viewWillAppear:(BOOL)animated{
    [self enterGoodsDetail];
    //获取通知中心单例对象
    NSNotificationCenter * center = [NSNotificationCenter defaultCenter];
    //添加当前类对象为一个观察者，name和object设置为nil，表示接收一切通
    [center addObserver:self selector:@selector(enterGoodsDetail) name:Notification_HNShoppingViewController object:nil];
}

//- (void)viewWillDisappear:(BOOL)animated {
//    [super viewWillDisappear:animated];
//
//        //移除
//        NSNotificationCenter * center = [NSNotificationCenter defaultCenter];
//        [center removeObserver:self name:Notification_HNShoppingViewController object:nil];
//    
//}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createTopView];
    self.title = @"商城";
    
    [self enterGoodsDetail];
    
//    _webViewUrl = [NSMutableString stringWithFormat:@"%@?sessionId=%@",url_web_Shopping,static_sessionId];
//    
//    _webViewUrl = [NSMutableString stringWithFormat:@"%@",[_webViewUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
//    NSURLRequest * _req = [NSURLRequest requestWithURL:[NSURL URLWithString:_webViewUrl]];
//    
//    _webView = [[UIWebView alloc]initWithFrame:CGRectMake(0,0, kScreen_Width, kScreen_Height - 50)];
//    _webView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleBottomMargin;
//    [_webView loadRequest:_req];
//    _webView.scrollView.bounces = NO;
//    _webView.suppressesIncrementalRendering = NO;
//    _webView.delegate = self;
//    [_webView setBackgroundColor:[AppConfig colorWithHexString:@"#ececec"]];
//    [self.view addSubview:_webView];
//    
//
//    UIButton *clickBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
//    [clickBtn setTitle:@"" forState:UIControlStateNormal];
//    [clickBtn setBackgroundColor:RGBA(255, 255, 255, 0)];
//    [clickBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//
//    clickBtn.frame = _webView.frame;//大小和位置
//    [clickBtn addTarget:self action:@selector(enterGoodsDetail) forControlEvents:UIControlEventTouchUpInside];
//    [self.view addSubview:clickBtn];
    
}

-(void)enterGoodsDetail{
    
    HNPharmacyViewController *vc = [[HNPharmacyViewController alloc]init];
    [self.navigationController pushViewController:vc animated:NO];
    
}

-(void)createTopView{
    UIView *topView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreen_Width, 64)];
    topView.backgroundColor = RGB(249, 249, 249);
    [self.view addSubview:topView];
    
//    _topTitle = [[UILabel alloc]initWithFrame:CGRectMake(kScreen_Width/2 - 60,20,120,44)];
//    _topTitle.numberOfLines = 1;
//    _topTitle.clipsToBounds = YES;
//    _topTitle.layer.cornerRadius = 4;
//    _topTitle.textAlignment = NSTextAlignmentCenter;
//    _topTitle.font = [UIFont systemFontOfSize:15];
//    _topTitle.textColor = RGBJ(44);
//    _topTitle.text = @"商城";
//    [topView addSubview:_topTitle];
//    
//    _topBackBtn = [UIButton buttonWithType:UIButtonTypeSystem];
//    [_topBackBtn setFont:[UIFont systemFontOfSize:15]];
//    [_topBackBtn setBackgroundColor:[UIColor whiteColor]];
//    [_topBackBtn setBackgroundImage:[UIImage imageNamed:@"xiangyou.png"] forState:UIControlStateNormal];
//    [_topBackBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//    _topBackBtn.frame = CGRectMake(8,28,24,24);
//    [_topBackBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
//    [topView addSubview:_topBackBtn];
    
}


@end
